﻿using System;
using System.Collections.Generic;

namespace Gumini.JulaDB.Data
{
    [Serializable]
    public class Table
    {
        private readonly TableDefinition _definition;
        private List<Row> _rows = new List<Row>();

        public Table(TableDefinition definition)
        {
            _definition = definition;
        }

        public TableDefinition Definition
        {
            get { return _definition; }
        } 

        public List<Row> Rows
        {
            get { return _rows; }
        }

        public int NumberOfRows
        {
            get { return _rows.Count; }
        }

        public void InsertRow(Row row)
        {
            _rows.Add(row);
        }

        public void SetRows(List<Row> rows)
        {
            _rows = rows;
        }

        public override string ToString()
        {
            return String.Format("Table name: {0}, rows: {1}", _definition.Name, _rows.Count);
        }
    }
}
